package com.nbsaas.boot.project.rest.resource;

import com.nbsaas.boot.jpa.data.core.BaseResource;
import com.nbsaas.boot.project.api.apis.ProjectApi;
import com.nbsaas.boot.project.api.domain.request.ProjectRequest;
import com.nbsaas.boot.project.api.domain.response.ProjectResponse;
import com.nbsaas.boot.project.api.domain.simple.ProjectSimple;
import com.nbsaas.boot.project.data.entity.Project;
import com.nbsaas.boot.project.data.repository.ProjectRepository;
import com.nbsaas.boot.project.rest.convert.ProjectEntityConvert;
import com.nbsaas.boot.project.rest.convert.ProjectResponseConvert;
import com.nbsaas.boot.project.rest.convert.ProjectSimpleConvert;
import jakarta.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.function.Function;
/**
 *   项目-业务接口实现
 */
@Transactional
@Service
public class ProjectResource extends BaseResource<Project, ProjectResponse, ProjectSimple, ProjectRequest> implements ProjectApi {

    @Resource
    private ProjectRepository projectRepository;

    @Override
    public JpaRepositoryImplementation<Project, Serializable> getJpaRepository() {
        return projectRepository;
    }

    @Override
    public Function<Project, ProjectSimple> getConvertSimple() {
        return new ProjectSimpleConvert();
    }

    @Override
    public Function<ProjectRequest, Project> getConvertForm() {
        return new ProjectEntityConvert();
    }

    @Override
    public Function<Project, ProjectResponse> getConvertResponse() {
        return new ProjectResponseConvert();
    }


}


